home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / amisl090.zip / REMOVE.C < prev    next >
C/C++ Source or Header  |  1992-09-12  |  4KB  |  122 lines

  1. /************************************************************************/
  2. /*                                    */
  3. /* REMOVE.C    Remove a specific AMIS-compliant TSR            */
  4. /* Public Domain 1992 Ralf Brown                    */
  5. /* Version 0.90                             */
  6. /* Last Edit: 9/12/92                            */
  7. /*                                                                      */
  8. /* Must be compiled in a large data model (compact recommended)        */
  9. /* ex.  TCC -mc REMOVE FINDTSRS.OBJ UNINSTAL.OBJ            */
  10. /*                                    */
  11. /************************************************************************/
  12.  
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <conio.h>
  16. #include <ctype.h>
  17. #include <string.h>
  18. #include <dos.h>
  19.  
  20. extern int find_TSRs(char *mpx_numbers, char *manuf, char *name) ;
  21. extern int AMIS_uninstall(int mpx_number) ;
  22.  
  23. /************************************************************************/
  24.  
  25. void usage(void)
  26. {
  27.    printf("Usage:\tREMOVE product\n") ;
  28.    printf("\tREMOVE manufacturer product\n") ;
  29.    printf("\t\tboth <manufacturer> and <product> may be abbreviated\n") ;
  30.    printf("\t\tif <product> is *, all TSRs will be removed\n") ;
  31.    exit(1) ;
  32. }
  33.  
  34. /************************************************************************/
  35.  
  36. int main(int argc,char **argv)
  37. {
  38.    char mpx_numbers[256] ;
  39.    union REGS regs ;
  40.    int found, i, status ;
  41.    char *manuf, *name ;
  42.    char far *sig ;
  43.       
  44.    printf("REMOVE\tPublic Domain 1992 Ralf Brown\n") ;
  45.    if (argc == 1 || argc > 3)
  46.       usage() ;
  47.    if (argc == 2)
  48.       {
  49.       manuf = NULL ;
  50.       name = argv[1] ;
  51.       }
  52.    else
  53.       {
  54.       manuf = argv[1] ;
  55.       name = argv[2] ;
  56.       }
  57.    if (strcmp(name,"*") == 0)
  58.       name = "" ;  /* remove ALL TSRs */
  59.    found = find_TSRs(mpx_numbers,manuf,name) ;    
  60.    switch (found)
  61.       {
  62.       case 0:
  63.      printf("No matching TSR found\n") ;
  64.      break ;
  65.       default:
  66.      printf("The specified name matches the following TSRs:\n") ;
  67.      printf("   Manufact  Product\n") ;
  68.      printf("   -------- --------\n") ;
  69.      for (i = 0 ; i < found ; i++)
  70.         {
  71.         regs.h.ah = mpx_numbers[i] ;
  72.         regs.h.al = 0 ;
  73.         int86(0x2D,®s,®s) ;
  74.         sig = MK_FP(regs.x.dx,regs.x.di) ;
  75.         printf("   %8.8s %8.8s\n",sig,sig+8) ;
  76.         }
  77.      printf("Remove all? [Y/N] ") ;
  78.      fflush(stdout) ;
  79.      if (toupper(getch()) != 'Y')
  80.         break ;
  81.      printf("\n") ;
  82.      /* fall through */
  83.       case 1:
  84.      for (i = 0 ; i < found ; i++)
  85.         {
  86.         regs.h.ah = mpx_numbers[i] ;
  87.         regs.h.al = 0 ;
  88.         int86(0x2D,®s,®s) ;    /* get TSR signature */
  89.         sig = MK_FP(regs.x.dx,regs.x.di) ;
  90.         printf("Attempting removal of %8.8s %8.8s.... ",sig,sig+8) ;
  91.         status = AMIS_uninstall(mpx_numbers[i]) ;
  92.         switch(status)
  93.            {
  94.            case 0:
  95.               printf("removal service not supported.\n") ;
  96.               break ;
  97.            case 1:
  98.               printf("removal unsuccessful.\n") ;
  99.               break ;
  100.            case 2:
  101.               printf("will remove itself when able.\n") ;
  102.               break ;
  103.            case 5:
  104.               printf("can't remove now, try again.\n") ;
  105.               break ;
  106.            case 3:  /* no resident remover, TSR still enabled */
  107.            case 4:  /* no resident remover, TSR now disabled */
  108.               /* these cases were handled by AMIS_uninstall */
  109.               /* fall through to 0xFF */
  110.            case 0xFF:
  111.               printf("successfully removed.\n") ;
  112.               break ;
  113.            default:
  114.               printf("unknown return code %2.02X\n",status) ;
  115.               break ;
  116.            }
  117.         }
  118.      break ;
  119.       }
  120.    return 0 ;
  121. }
  122.